import service from "@/path/service"
import {
  TypeMerchantWxLogin, TypeGetUserByid, TypeRefreshToken
} from "./type"
/**微信登录 */
export function merchantWxLogin(params: TypeMerchantWxLogin.parameter) {
  return service.post<{ userinfo: TypeMerchantWxLogin.returnedVal }>("user/login", { data: params, skipToken: true, loading: false }).then(r => r.data)
}
/**code登录 */
export function usercodeLogin(params: TypeRefreshToken.parameter) {
  return service.get<TypeGetUserByid.returnedVal>(`user/codeLogin`, { skipToken: true, loading: false, header: { token: params.refreshToken } })
}
/**获取新的用户信息 */
export function getUserByid(token?: string) {
  return service.get<{ userinfo: TypeMerchantWxLogin.returnedVal }>(`user/getUserinfo`, { skipToken: true, header: { token }, loading: false })
}
/**刷新用户token */
export function refreshToken() {
  return service.post<{ token: string }>(`token/refresh`, { skipToken: true })
}